<!--
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-05-11 08:47:22
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2023-12-15 13:41:35
 * @FilePath: /hr_new_vue3/src/views/Management/Organization/PositionManagement/SystemManagement/Components/Management/Components/MainSide/FileDetail/Components/Main/Components/Container/Components/PositionHistoryOnJob/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 职位档案历任人员 -->
<template>
  <div class="wrap">
    <a-input-search
      :style="{ width: '320px', marginBottom: '20px' }"
      placeholder="请输入姓名"
      search-button
      v-model="searchVal"
      @search="onSearch"
      @press-enter="onSearch"
    >
      <template #button-icon>
        <icon-search />
      </template>
    </a-input-search>
    <TableTurn :tableData="getData" ref="tableRef">
      <a-table-column title="姓名" data-index="name"></a-table-column>
      <a-table-column title="人员编号" data-index="jobNumber"></a-table-column>
      <!-- <a-table-column title="职位名称" data-index="headcount"></a-table-column> -->
      <a-table-column
        title="主/兼职类型"
        data-index="natureWork"
      ></a-table-column>
      <a-table-column title="部门" data-index="department">
        <template #cell="{ record }">
          {{ dept.find((item: any) => item.id == record.department)?.name }}
        </template>
      </a-table-column>
      <a-table-column
        title="职务"
        data-index="associatedDuties"
      ></a-table-column>
      <a-table-column title="职级" data-index="rank"></a-table-column>
      <a-table-column title="入职时间" data-index="joinTime"></a-table-column>
      <a-table-column title="离职时间" data-index="leaveTime"></a-table-column>
      <a-table-column title="操作" fixed="right">
        <template #cell="{ record }">
          <a-button type="text" @click="goDetail(record.id)">查看</a-button>
        </template>
      </a-table-column>
    </TableTurn>
    <Modal v-model:visible="visible"> </Modal>
  </div>
</template>

<script lang="ts" setup>
import { GetPositionOnJob } from '@/apis/management/organization/positionManagement';
import { getFlatDept } from '@/utils/common';

const route = useRoute();

// 档案id
let id = Number(route.query.id);
let ownerType = Number(route.query.ownerType);
onBeforeRouteUpdate((to) => {
  id = Number(to.query.id);
  ownerType = Number(to.query.ownerType);
  getData();
});

let tableRef = ref();
let searchVal = ref('');
let visible = ref(false);
// 获取列表数据
const getData = async (pageData?: any) => {
  try {
    // const res = await GetPositionOnJob({
    //   ...pageData,
    //   id,
    //   name: searchVal.value,
    //   onboarding: 2 // 在职人员传1
    // });
    // return Promise.resolve(res);
  } catch (error: unknown) {
    console.log(error);
  }
};

let dept: any = []; // 储存部门数据
onMounted(async () => {
  dept = await getFlatDept();
});

const onSearch = () => {
  tableRef.value.loadData();
};

const goDetail = (id: number) => {
  visible.value = true;
};
</script>

<style scoped lang="less"></style>
